package com.yaowk.common.validator;

import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.validate.Validator;
import com.yaowk.common.kit.ResultKit;
import com.yaowk.common.kit.ServiceCode;

/**
 * 参数验证基类
 *
 * @authc yaowk
 * 2017/4/20
 */
public abstract class BaseValidator extends Validator {

    protected static final String ERROR_CODE = "error_msg";

    @Override
    protected abstract void validate(Controller c);

    @Override
    protected void handleError(Controller c) {
        c.renderJson(ResultKit.fail(c.getAttrForStr(ERROR_CODE), ServiceCode.ERROR));
    }
}
